package com.example.boot.produce.rabbitmq.web;

import com.example.boot.produce.rabbitmq.service.OrderService;
import com.example.boot.rabbitmq.rabbitmqcommon.model.Order;
import com.example.boot.rabbitmq.rabbitmqcommon.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;


    @RequestMapping(value = "/order",method = RequestMethod.GET)
    public Result city(@RequestParam("name") String name) throws Exception {
       String uuid =  UUID.randomUUID().toString();
        Order order = new Order();
        order.setName(name);
        order.setId(uuid);
        order.setMessageId(System.currentTimeMillis()+"$"+uuid);
        orderService.createOrder(order);
        return Result.success();
    }


}
